/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "CARGO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cargo.findAll", query = "SELECT c FROM Cargo c"),
    @NamedQuery(name = "Cargo.findByCarCod", query = "SELECT c FROM Cargo c WHERE c.carCod = :carCod"),
    @NamedQuery(name = "Cargo.findByCarNom", query = "SELECT c FROM Cargo c WHERE c.carNom = :carNom"),
    @NamedQuery(name = "Cargo.findByCarDesc", query = "SELECT c FROM Cargo c WHERE c.carDesc = :carDesc"),
    @NamedQuery(name = "Cargo.findByCarEst", query = "SELECT c FROM Cargo c WHERE c.carEst = :carEst")})
public class Cargo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "CAR_COD")
    private Integer carCod;
    @Column(name = "CAR_NOM")
    private String carNom;
    @Column(name = "CAR_DESC")
    private String carDesc;
    @Column(name = "CAR_EST")
    private Short carEst;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "carCod", fetch = FetchType.LAZY)
    private List<PersonalUnidad> personalUnidadList;

    public Cargo() {
    }

    public Cargo(Integer carCod) {
        this.carCod = carCod;
    }

    public Integer getCarCod() {
        return carCod;
    }

    public void setCarCod(Integer carCod) {
        this.carCod = carCod;
    }

    public String getCarNom() {
        return carNom;
    }

    public void setCarNom(String carNom) {
        this.carNom = carNom;
    }

    public String getCarDesc() {
        return carDesc;
    }

    public void setCarDesc(String carDesc) {
        this.carDesc = carDesc;
    }

    public Short getCarEst() {
        return carEst;
    }

    public void setCarEst(Short carEst) {
        this.carEst = carEst;
    }

    @XmlTransient
    public List<PersonalUnidad> getPersonalUnidadList() {
        return personalUnidadList;
    }

    public void setPersonalUnidadList(List<PersonalUnidad> personalUnidadList) {
        this.personalUnidadList = personalUnidadList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (carCod != null ? carCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cargo)) {
            return false;
        }
        Cargo other = (Cargo) object;
        if ((this.carCod == null && other.carCod != null) || (this.carCod != null && !this.carCod.equals(other.carCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Cargo[ carCod=" + carCod + " ]";
    }
    
}
